<?php	
namespace Shopadmin\Model;
use Think\Model;
class ImgUploadModel{
	public $sessionKey;
	public $imgPath;

	public function upload(){
		Vendor('taobaosdk.top.TopClient');
		Vendor('taobaosdk.top.RequestCheckUtil');
		Vendor('taobaosdk.top.request.PictureUploadRequest');
		$this->c =  new \TopClient();
		$this->c->appkey=C('SM_KEY');
		$this->c->secretKey=C('SM_SECRET');
		$req = new \PictureUploadRequest;
		$req->setPictureCategoryId(0);
		//附件上传的机制参见PHP CURL文档，在文件路径前加@符号即可
		$req->setImg("@".$this->imgPath);
		$req->setImageInputTitle("xl.uz.taobao.com.jpg");
		$req->setTitle("订单抽大奖图片【勿删】");
		$resp = $this->c->execute($req, $this->sessionKey);
		if($resp->code){
			$this->err = $resp->msg.$resp->sub_msg;
		}else{
			$this->pic_url = (string)$resp->picture->picture_path;
		}
	}
	public function jaeupload(){
		Vendor("imgupload.TopClient");
		Vendor("imgupload.PictureUploadRequest");
		$c = new \TopClient;
		$c->appkey = C('SM_KEY');
		$c->secretKey = C('SM_SECRET');
		$req = new \PictureUploadRequest;
		$req->setPictureCategoryId(0);
		$req->setImg($this->imgPath);
		$req->setImageInputTitle("xl.uz.taobao.com.jpg");
		$req->setTitle("订单抽大奖图片【勿删】");
		$resp = $c->execute($req, $this->sessionKey);
		if($resp->code){
			$this->err = $resp->msg.$resp->sub_msg;
		}else{
			$this->pic_url = (string)$resp->picture->picture_path;
		}
	}
}